package com.zzjson;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.bootstrap.config.PropertySourceLocator;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年11月08日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
@SpringBootApplication
public class SpringCloudConfigApplication {
	public static void main(String[] args) {
		SpringApplication springApplication = new SpringApplication(SpringCloudConfigApplication.class);
		springApplication.run(args);
	}

	@Configuration
	@Order(Ordered.HIGHEST_PRECEDENCE)
	public static class MyPropertySourceLocator implements PropertySourceLocator {

		@Override
		public PropertySource<?> locate(Environment environment) {
			Map<String, Object> source = new HashMap<>();
			source.put("server.port", 9090);
			MapPropertySource mapPropertySource = new MapPropertySource("my-property-source", source);
			return mapPropertySource;

		}
	}
}